import '../public.dart';
import '../views/root/root.dart';
import '../views/form/view.dart';
import '../views/typelist/view.dart';
import '../views/group/list.dart';
import '../views/about/view.dart';
import '../views/mine/feedBack.dart';
import '../views/login/view.dart';
import '../views/regist/view.dart';

class RouteHub {
  /// 是否需要登录授权
  bool authorize;
  late Widget Function(Object?) builder;

  RouteHub(dynamic builder, {this.authorize = false}) {
    if (builder is Widget Function(Object?)) {
      this.builder = builder;
    } else {
      this.builder = (_) => builder;
    }
  }
}

class Routers {
  static String main = '/';
  static String login = 'login';
  static String regist = 'regist';
  static String form = 'form';
  static String setting = 'setting';
  static String types = 'types';
  static String groupList = 'groupList';
  static String about = 'about';
  static String feedBack = 'feedBack';

  static Map<String, RouteHub> routeDeictionary = {
    main: RouteHub((arg) => TabNavigator(arg), authorize: true),
    form: RouteHub((arg) => AccountForm(arg)),
    types: RouteHub(const TypeSelect()),
    groupList: RouteHub((arg) => GroupList(arg)),
    about: RouteHub(const AboutUs()),
    feedBack: RouteHub(const FeedBackView()),
    login: RouteHub(const LoginPage()),
    regist: RouteHub(const RegistPage())
  };
}
